<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>定位的层级2</title>
    <style>
        .outer {
            height: 400px;
            background-color: #888;
            position: relative;

        }

        .inner {
            font-size: 20px;
            background-color: orange;
            padding: 20px;
            border: 10px black solid;
            position: absolute;

            /*width只保证内容区100撑起父元素,没考虑边框和padding*/
            /*width: 100%;*/
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;


        }
        .outer2 {
            height: 400px;
            background-color: #888;
            position: relative;

        }
        .inner2 {
            width: 400px;
            height: 100px;
            background-color: orange;
            font-size: 20px;
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            margin: auto;
        }

</style>
</head>


<body>
<div class="outer">
    <div class="inner">inner</div>
</div>
<hr>
<div class="outer2">
    <div class="inner2">inner2</div>
</div>
<hr>
居中方案必须有宽高
<img src="../../images/定位特殊应用.png" width="450px">
</body>
</html>